package com.eascs.workflow.log;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.dubbo.config.annotation.Reference;
import com.eascs.app.dao.PageResult;
import com.eascs.site.view.BaseRestResult;
import com.eascs.site.view.ViewContext;
import com.eascs.workflow.common.controller.BaseViewController;
import com.eascs.workflow.common.entity.sys.UserLogEntity;
import com.eascs.workflow.common.service.sys.UserLogService;

@RequestMapping("/userLog")
@Controller
public class UserLogController extends BaseViewController {

    @Reference
    private UserLogService userLogService;

    @RequestMapping({"", "index"})
    public String index(){
        PageResult<UserLogEntity> page = new PageResult<UserLogEntity>(10, 0, 20);
        page = userLogService.queryPage(page);
        ViewContext.put("items", page.getData());
        ViewContext.put("count", 46);
        ViewContext.put("totalpage",10);
        ViewContext.put("page",3);
        return "/log/index";
    }

    @RequestMapping(value = "/findByPage", method = RequestMethod.GET)
    @ResponseBody
    public BaseRestResult<PageResult<UserLogEntity>> findByPage(int pageIndex, int pageSize){
        PageResult<UserLogEntity> page = new PageResult<UserLogEntity>(pageSize, pageIndex, 20);
        page = userLogService.queryPage(page);
        return BaseRestResult.buildRestResult(page);
    }
}
